﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
    CodeBehind="CadastrarAluno.aspx.cs" Inherits="RepositorioDeMonografia.Aluno" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <fieldset class="CadastraAluno">
        <legend>Cadastrar Aluno</legend>
        <form id="form1" method="post" action="">
        <div>
          

                <tr>
                    <td class="style2">
                            <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" 
                                CellPadding="4" DataKeyNames="Matricula" DataSourceID="SqlDataSourceAluno" 
                                DefaultMode="Insert" ForeColor="#333333" GridLines="None" Height="50px" 
                                Width="125px">
                               
                                <Fields>
                                    <asp:TemplateField ConvertEmptyStringToNull="False" HeaderText="Matricula" 
                                        SortExpression="Matricula">
                                        <EditItemTemplate>
                                            <asp:DynamicControl ID="DynamicControl1" runat="server" DataField="Matricula" 
                                                Mode="Edit" />
                                        </EditItemTemplate>
                                        <InsertItemTemplate>
                                            <asp:TextBox ID="TextBox8" runat="server" Text='<%# Bind("Matricula") %>' Height="20px" Width="250px"></asp:TextBox>
                                        </InsertItemTemplate>
                                        <ItemTemplate>
                                            <asp:DynamicControl ID="DynamicControl1" runat="server" DataField="Matricula" 
                                                Mode="ReadOnly" />
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="Nome" SortExpression="Nome">
                                        
                                        <InsertItemTemplate>
                                            <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Nome") %>' Height="20px" Width="250px"></asp:TextBox>
                                        </InsertItemTemplate>
                                       
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="Curso" SortExpression="Id_Curso">
                                     
<InsertItemTemplate>
                                            <asp:DropDownList ID="DropDownList1" runat="server" 
                                                DataSourceID="SqlDataSourceCurso" DataTextField="Nome" DataValueField="Id" 
                                                Height="36px" Width="236px">
                                            </asp:DropDownList>
                                            <asp:SqlDataSource ID="SqlDataSourceCurso" runat="server" 
                                                ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
                                                SelectCommand="SELECT [Id], [Nome] FROM [Curso]"></asp:SqlDataSource>
                                        
</InsertItemTemplate>
                                       
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="Endereco" SortExpression="Endereco">
                                        
                                        <InsertItemTemplate>
                                            <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Endereco") %>' Height="20px" Width="250px"></asp:TextBox>
                                        </InsertItemTemplate>
                                        
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="Telefone" SortExpression="Telefone">
                                       
                                        <InsertItemTemplate>
                                            <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("Telefone") %>' Height="20px" Width="250px"></asp:TextBox>
                                        </InsertItemTemplate>
                                        
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="Email" SortExpression="Email">
                                        
                                        <InsertItemTemplate>
                                            <asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("Email") %>' Height="20px" Width="250px"></asp:TextBox>
                                        </InsertItemTemplate>
                                        
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="Celular" SortExpression="Celular">
                                       
                                        <InsertItemTemplate>
                                            <asp:TextBox ID="TextBox5" runat="server" Text='<%# Bind("Celular") %>' Height="20px" Width="250px"></asp:TextBox>
                                        </InsertItemTemplate>
                                        
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="Orientador" SortExpression="Id_Orientador">
                                        
                                        <InsertItemTemplate>
                                            <asp:DropDownList ID="DropDownList2" runat="server" 
                                                DataSourceID="SqlDataSourceOrientador" DataTextField="Nome" DataValueField="Id" 
                                                Height="28px" Width="238px">
                                            </asp:DropDownList>
                                            <asp:SqlDataSource ID="SqlDataSourceOrientador" runat="server" 
                                                ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
                                                SelectCommand="SELECT [Id], [Nome] FROM [Orientador]"></asp:SqlDataSource>
                                        
                                        </InsertItemTemplate>
                                        <ItemTemplate>
                                            <asp:Label ID="Label3" runat="server" Text='<%# Bind("Id_Orientador") %>' Height="20px" Width="250px"></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:CommandField 
                                        ShowInsertButton="True" ButtonType="Button" CancelText="Limpar" 
                                        InsertText="Cadastrar" />
                                </Fields>
                              
                            </asp:DetailsView>
                            <asp:SqlDataSource ID="SqlDataSourceAluno" runat="server" 
                                ConflictDetection="CompareAllValues" 
                                ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
                                DeleteCommand="DELETE FROM [Aluno] WHERE [Matricula] = @original_Matricula AND (([Nome] = @original_Nome) OR ([Nome] IS NULL AND @original_Nome IS NULL)) AND (([Id_Curso] = @original_Id_Curso) OR ([Id_Curso] IS NULL AND @original_Id_Curso IS NULL)) AND (([Endereco] = @original_Endereco) OR ([Endereco] IS NULL AND @original_Endereco IS NULL)) AND (([Telefone] = @original_Telefone) OR ([Telefone] IS NULL AND @original_Telefone IS NULL)) AND (([Email] = @original_Email) OR ([Email] IS NULL AND @original_Email IS NULL)) AND (([Celular] = @original_Celular) OR ([Celular] IS NULL AND @original_Celular IS NULL)) AND (([Id_Monografia] = @original_Id_Monografia) OR ([Id_Monografia] IS NULL AND @original_Id_Monografia IS NULL)) AND (([Id_Orientador] = @original_Id_Orientador) OR ([Id_Orientador] IS NULL AND @original_Id_Orientador IS NULL))" 
                                InsertCommand="INSERT INTO [Aluno] ([Nome], [Id_Curso], [Endereco], [Telefone], [Email], [Celular], [Id_Monografia], [Id_Orientador]) VALUES (@Nome, @Id_Curso, @Endereco, @Telefone, @Email, @Celular, @Id_Monografia, @Id_Orientador)" 
                                OldValuesParameterFormatString="original_{0}" 
                                SelectCommand="SELECT [Matricula], [Nome], [Id_Curso], [Endereco], [Telefone], [Email], [Celular], [Id_Monografia], [Id_Orientador] FROM [Aluno]" 
                                UpdateCommand="UPDATE [Aluno] SET [Nome] = @Nome, [Id_Curso] = @Id_Curso, [Endereco] = @Endereco, [Telefone] = @Telefone, [Email] = @Email, [Celular] = @Celular, [Id_Monografia] = @Id_Monografia, [Id_Orientador] = @Id_Orientador WHERE [Matricula] = @original_Matricula AND (([Nome] = @original_Nome) OR ([Nome] IS NULL AND @original_Nome IS NULL)) AND (([Id_Curso] = @original_Id_Curso) OR ([Id_Curso] IS NULL AND @original_Id_Curso IS NULL)) AND (([Endereco] = @original_Endereco) OR ([Endereco] IS NULL AND @original_Endereco IS NULL)) AND (([Telefone] = @original_Telefone) OR ([Telefone] IS NULL AND @original_Telefone IS NULL)) AND (([Email] = @original_Email) OR ([Email] IS NULL AND @original_Email IS NULL)) AND (([Celular] = @original_Celular) OR ([Celular] IS NULL AND @original_Celular IS NULL)) AND (([Id_Monografia] = @original_Id_Monografia) OR ([Id_Monografia] IS NULL AND @original_Id_Monografia IS NULL)) AND (([Id_Orientador] = @original_Id_Orientador) OR ([Id_Orientador] IS NULL AND @original_Id_Orientador IS NULL))">
                                <DeleteParameters>
                                    <asp:Parameter Name="original_Matricula" Type="Int32" />
                                    <asp:Parameter Name="original_Nome" Type="String" />
                                    <asp:Parameter Name="original_Id_Curso" Type="Int32" />
                                    <asp:Parameter Name="original_Endereco" Type="String" />
                                    <asp:Parameter Name="original_Telefone" Type="String" />
                                    <asp:Parameter Name="original_Email" Type="String" />
                                    <asp:Parameter Name="original_Celular" Type="String" />
                                    <asp:Parameter Name="original_Id_Monografia" Type="Int32" />
                                    <asp:Parameter Name="original_Id_Orientador" Type="Int32" />
                                </DeleteParameters>
                                <InsertParameters>
                                    <asp:Parameter Name="Nome" Type="String" />
                                    <asp:Parameter Name="Id_Curso" Type="Int32" />
                                    <asp:Parameter Name="Endereco" Type="String" />
                                    <asp:Parameter Name="Telefone" Type="String" />
                                    <asp:Parameter Name="Email" Type="String" />
                                    <asp:Parameter Name="Celular" Type="String" />
                                    <asp:Parameter Name="Id_Monografia" Type="Int32" />
                                    <asp:Parameter Name="Id_Orientador" Type="Int32" />
                                </InsertParameters>
                                <UpdateParameters>
                                    <asp:Parameter Name="Nome" Type="String" />
                                    <asp:Parameter Name="Id_Curso" Type="Int32" />
                                    <asp:Parameter Name="Endereco" Type="String" />
                                    <asp:Parameter Name="Telefone" Type="String" />
                                    <asp:Parameter Name="Email" Type="String" />
                                    <asp:Parameter Name="Celular" Type="String" />
                                    <asp:Parameter Name="Id_Monografia" Type="Int32" />
                                    <asp:Parameter Name="Id_Orientador" Type="Int32" />
                                    <asp:Parameter Name="original_Matricula" Type="Int32" />
                                    <asp:Parameter Name="original_Nome" Type="String" />
                                    <asp:Parameter Name="original_Id_Curso" Type="Int32" />
                                    <asp:Parameter Name="original_Endereco" Type="String" />
                                    <asp:Parameter Name="original_Telefone" Type="String" />
                                    <asp:Parameter Name="original_Email" Type="String" />
                                    <asp:Parameter Name="original_Celular" Type="String" />
                                    <asp:Parameter Name="original_Id_Monografia" Type="Int32" />
                                    <asp:Parameter Name="original_Id_Orientador" Type="Int32" />
                                </UpdateParameters>
                            </asp:SqlDataSource>
                            <br />
                            <br />
                    </td>                    
                </tr>
            </div>
        </form>
    </fieldset>    
</asp:Content>
